import 'dart:convert';

int calculate() {
  return 6 * 7;
}

class DataConverter {
  /// Convert JSON string to Map
  static Map<String, dynamic> jsonToMap(String jsonStr) {
    return json.decode(jsonStr) as Map<String, dynamic>;
  }

  /// Convert Map to JSON string
  static String mapToJson(Map<String, dynamic> map) {
    return json.encode(map);
  }

  /// Filter map entries by key pattern
  static Map<String, dynamic> filterMap(
    Map<String, dynamic> map,
    bool Function(String key) predicate,
  ) {
    return Map.fromEntries(map.entries.where((entry) => predicate(entry.key)));
  }

  /// Sort map by keys
  static Map<String, dynamic> sortMapByKey(Map<String, dynamic> map) {
    final sortedKeys = map.keys.toList()..sort();
    return Map.fromEntries(sortedKeys.map((key) => MapEntry(key, map[key])));
  }
}
